package org.manon.json.asm.ser;

import org.manon.json.asm.ASMBaseGenerator;
import org.manon.json.asm.ASMContextSerializer;
import org.manon.json.asm.MethodVisitorTemplate;
import org.manon.json.meta.MetaProperty;
import org.objectweb.asm.MethodVisitor;
import org.objectweb.asm.Opcodes;

public final class CreateFieldTemplate extends MethodVisitorTemplate<ASMContextSerializer> {

	private final ASMBaseGenerator _generator;
	
	public CreateFieldTemplate(ASMBaseGenerator generator) {
		super(Opcodes.ACC_STATIC,"<clinit>", "()V", null, null);
		_generator = generator;
	}
	/**
	 * @see org.manon.json.asm.MethodVisitorTemplate#doCreate(org.manon.json.asm.ASMContext, org.objectweb.asm.MethodVisitor)
	 */
	@Override
	protected void doCreate(ASMContextSerializer context,MethodVisitor methodVisitor) throws Exception {
		CreateFieldVisitor visitor = new CreateFieldVisitor(_generator, context,methodVisitor);
		for (MetaProperty property : context.getEntity() .getProperties()) {
			property.accept(visitor);
		}	
	}

}